﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.PO;
using Com.CMS263.BLL;
using Com.CMS263.Util;
using System.IO;

namespace Com.CMS263.Web.manage
{
    public partial class MarryShowAdd : System.Web.UI.Page
    {
        TVstationBLL tvbll = new TVstationBLL();
        public  IList<TVstation> tvlist = new List<TVstation>();
        protected void Page_Load(object sender, EventArgs e)
        {           
                tvlist = tvbll.GetModelList("from TVstation");               
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string strDay = DateTime.Now.ToString("yyyy-MM-dd");
            string savePath = Server.MapPath("/ArtUpFile/" + strDay);
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            string FilePath = strDay + "/" + UpLoadFileUtil.UpLoadFile(Request.Files["FilePath"], savePath);

            MarryShow ms=new MarryShow();
            MarryShowBLL msbll = new MarryShowBLL();
            string title = StringUtil.checkStr(Request["title"]);
            string man = StringUtil.checkStr(Request["man"]);
            string woman = StringUtil.checkStr(Request["woman"]);
            string info = StringUtil.checkStr(Request["info"]);
            string description = StringUtil.checkStr(Request["description"]);

            int tvId = int.Parse(Request["tvName"]);
            tvbll.tv = (TVstation)tvbll.FindModelById("TVstation", tvId);
            string tvName = tvbll.tv.Name;

            ms.TvName = tvName;
            ms.Woman = woman;
            ms.Man = man;
            ms.Title = title;
            ms.ShowTime =DateTime.Parse( Request["showTime"]);
            ms.OrderNum = 0;
            ms.Info = info;
            ms.Description = description;
            ms.AddDate = DateTime.Now;
            ms.TvId = tvId;
            ms.FilePath = FilePath;
            ms.OrderNum = int.Parse(Request["orderNum"]);
            msbll.entity = ms;
            if (msbll.Add())
            {
                StringUtil.Alert("添加成功！", "marryshowList.aspx");
            }
            else
            {
                StringUtil.Alert("添加失败！", "-1");
            }
            
        }
    }
}
